<?php
namespace app\admin\controller;

class Base{
    
    public function __construct(){
        header("Access-Control-Allow-Origin:*");
        date_default_timezone_set('PRC');
    }
    protected function returnCode($code,$data=[]){
        header('Content-type:application/json');
        if($code == 0){
            $arr = array(
                'code'=>$code,
                'msg'=>'成功',
                'data' => $data
            );
        }else{
            $arr = array(
                'code' => $code,
                'msg' => $data
            );
        }
        echo json_encode($arr);
        if($code != 0){
            exit;
        }
    }
}